import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'
// import Home from '@/pages/home/Home'
// import City from '@/pages/city/City'
// import Detail from '@/pages/detail/Detail'

Vue.use(Router)
//异步加载组件
//当文件足够大的时候才使用异步组件，因为每次切换页面就要请求一次http，所以文件不是足够大的话使用同步加载组件
export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Home',
      component: () => import('@/pages/home/Home')
    },{
      path: '/city',
      name: 'City',
      component: () => import('@/pages/city/City')
    },{
      path: '/detail/:id',
      name: 'Detail',
      component: () => import('@/pages/detail/Detail')
    }],
    scrollBehavior(to, from, savedPosition){
      return { x:0 , y:0 }
    }
})
